﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Ge.WebApi.Services;
using System.Data;

namespace Ge.WebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class HomeController : ControllerBase
    {
        private readonly ILogger<HomeController> _logger;

        private readonly IDapper _dapper;

        public HomeController(ILogger<HomeController> logger, IDapper dapper)
        {
            _logger = logger;
            _dapper = dapper;
        }

        //方法1
        [HttpGet]
        public IActionResult getResult()
        {
            //TEST 数据库链路
            var totalcount = _dapper.Get<int>($"select COUNT(*) from AbpAuditLogs WHERE 1=1", null,
                   commandType: CommandType.Text);
            _logger.LogInformation("进入getResult");
            return Ok(totalcount);
        }
    }
}
